<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Accept a connection on a socket created by stream_socket_server</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.stream-set-write-buffer.html">stream_set_write_buffer</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.stream-socket-client.html">stream_socket_client</a></div>
 <div class="up"><a href="ref.stream.html">Stream 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.stream-socket-accept" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">stream_socket_accept</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">stream_socket_accept</span> &mdash; <span class="dc-title">Accept a connection on a socket created by <span class="function"><a href="function.stream-socket-server.html" class="function">stream_socket_server()</a></span></span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.stream-socket-accept-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> <span class="methodname"><strong>stream_socket_accept</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$server_socket</code></span>
   [, <span class="methodparam"><span class="type">float</span> <code class="parameter">$timeout</code><span class="initializer"> = ini_get(&quot;default_socket_timeout&quot;)</span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$peername</code></span>
  ]] )</div>

  <p class="para rdfs-comment">
   Accept a connection on a socket previously created by
   <span class="function"><a href="function.stream-socket-server.html" class="function">stream_socket_server()</a></span>.
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-function.stream-socket-accept-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">server_socket</code></em></dt>

     <dd>

      <p class="para">
       The server socket to accept a connection from.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">timeout</code></em></dt>

     <dd>

      <p class="para">
       Override the default socket accept timeout. Time should be given in
       seconds.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">peername</code></em></dt>

     <dd>

      <p class="para">
       Will be set to the name (address) of the client which connected, if
       included and available from the selected transport.
      </p>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <p class="para">
        Can also be determined later using
        <span class="function"><a href="function.stream-socket-get-name.html" class="function">stream_socket_get_name()</a></span>.
       </p>
      </p></blockquote>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.stream-socket-accept-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns a stream to the accepted socket connection 或者在失败时返回 <strong><code>FALSE</code></strong>.
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.stream-socket-accept-notes">
  <h3 class="title">注释</h3>
  <div class="warning"><strong class="warning">Warning</strong>
   <p class="para">
    This function should not be used with UDP server sockets. Instead, use
    <span class="function"><a href="function.stream-socket-recvfrom.html" class="function">stream_socket_recvfrom()</a></span> and
    <span class="function"><a href="function.stream-socket-sendto.html" class="function">stream_socket_sendto()</a></span>.
   </p>
 </div>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.stream-socket-accept-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.stream-socket-server.html" class="function" rel="rdfs-seeAlso">stream_socket_server()</a> - Create an Internet or Unix domain server socket</span></li>
    <li class="member"><span class="function"><a href="function.stream-socket-get-name.html" class="function" rel="rdfs-seeAlso">stream_socket_get_name()</a> - Retrieve the name of the local or remote sockets</span></li>
    <li class="member"><span class="function"><a href="function.stream-set-blocking.html" class="function" rel="rdfs-seeAlso">stream_set_blocking()</a> - Set blocking/non-blocking mode on a stream</span></li>
    <li class="member"><span class="function"><a href="function.stream-set-timeout.html" class="function" rel="rdfs-seeAlso">stream_set_timeout()</a> - Set timeout period on a stream</span></li>
    <li class="member"><span class="function"><a href="function.fgets.html" class="function" rel="rdfs-seeAlso">fgets()</a> - 从文件指针中读取一行</span></li>
    <li class="member"><span class="function"><a href="function.fgetss.html" class="function" rel="rdfs-seeAlso">fgetss()</a> - 从文件指针中读取一行并过滤掉 HTML 标记</span></li>
    <li class="member"><span class="function"><a href="function.fwrite.html" class="function" rel="rdfs-seeAlso">fwrite()</a> - 写入文件（可安全用于二进制文件）</span></li>
    <li class="member"><span class="function"><a href="function.fclose.html" class="function" rel="rdfs-seeAlso">fclose()</a> - 关闭一个已打开的文件指针</span></li>
    <li class="member"><span class="function"><a href="function.feof.html" class="function" rel="rdfs-seeAlso">feof()</a> - 测试文件指针是否到了文件结束的位置</span></li>
    <li class="member"><a href="ref.curl.html" class="xref">cURL 函数</a></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.stream-set-write-buffer.html">stream_set_write_buffer</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.stream-socket-client.html">stream_socket_client</a></div>
 <div class="up"><a href="ref.stream.html">Stream 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
